import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import { visualizer } from 'rollup-plugin-visualizer'

import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import AutoImport from 'unplugin-auto-import/vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
    base: "./",
    plugins: [
        vue(),
        visualizer(),
        AutoImport({
            // resolvers: [ElementPlusResolver()],
            imports: ['vue']
        }),
        // Components({
        //     resolvers: [ElementPlusResolver()],
        // })
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    // build: {
    //     chunkSizeWarningLimit: 800,
    //     rollupOptions: {
    //         output: {
    //             chunkFileNames: 'assets/js/[name]-[hash].js',
    //             entryFileNames: 'assets/js/[name]-[hash].js',
    //             assetFileNames: 'assets/static/[ext]/[name]-[hash].[ext]'
    //         }
    //     }
    // },
    server: {
        host: '0.0.0.0',
        port: 80,
        proxy: {
            '/api': {
                target: 'https://zyk.icve.com.cn',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '/')
            }
        }
    }
})
